package com.hqd.ch03.v16.aop.framework;

import com.hqd.ch03.v16.aopalliance.intercept.MethodInterceptor;
import org.apache.commons.collections4.CollectionUtils;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

/**
 * advice管理类
 */
public class AdvisedSupport {
    private List<MethodInterceptor> advisors = new ArrayList<>();

    public void addAdvisors(Collection<MethodInterceptor> advisors) {
        if (CollectionUtils.isNotEmpty(advisors)) {
            this.advisors.addAll(advisors);
        }
    }

    public void addAdvisor(MethodInterceptor advisor) {
        if (advisor != null) {
            this.advisors.add(advisor);
        }
    }

    public List<MethodInterceptor> getAdvisors() {
        return advisors;
    }
}
